<cfif Not IsDefined("id")>
	<cfabort>
</cfif>

<cfquery name="file" datasource="exp">
	SELECT *
	FROM filestore
	WHERE id = #id#
</cfquery>

<cfif #file.recordcount# eq 1>
	<cfset path = "#ExpandPath( './' & file.filepath )#">
	<cfif #FileExists(path)#>
	<cfheader
	name="content-disposition"
	value="attachment; filename=#file.filename#"
	/>
	 
	<!--- Stream the file to the client. --->
	<cfcontent
	type="#file.mimetype#"
	file="#path#"
	/>
	</cfif>
<cfelse>
	<cfset session.message = "File ID: #id#, was not found, this has been reported.">
</cfif>

